package j2024.j202408;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class j0801 {
    public String formatString (String str, char[] arg) {
        // write code here
        int a = 0;
        char[] s = str.toCharArray();
        int i = 0;
        StringBuilder sb = new StringBuilder();
        while(i<s.length){
            if(s[i]=='%' && s[i+1]=='s' && i<s.length-1){
                sb.append(arg[a]);
                a++;
                i+=2;
            }else{
                sb.append(s[i]);
                i++;
            }
        }
        while(a<arg.length){
            sb.append(arg[a++]);
        }
        return sb.toString();
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int n = in.nextInt();
        int begin  = 0;
        int max = 0;
        int left = 0;
        int right = 0;
        int maxcount = 0,count = 0;
        while(right < str.length()){
            if(str.charAt(right)=='C' || str.charAt(right)=='G'){
                count++;
            }
            while(right-left+1>n){
                if(str.charAt(left)=='C' || str.charAt(left) == 'G'){
                    count--;
                    left++;
                }
            }
            if(count>maxcount){
                begin = left;
                maxcount = count;
            }
        }
        for (int i = begin; i <begin+n ; i++) {
            System.out.print(str.charAt(i));
        }
    }

    public static void main(String[] args) {
        Scanner in  =new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int ret = 0;

        for (int i = Math.max(a,10); i <= b; i++) {
            ret+=check(i);
        }
        System.out.println(ret);
    }
    public static int check(int x){
        int[] arr = new int[10];
        int n = 0;
        while(x!=0){
            arr[n++] = x%10;
            x/=10;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(i!=j && arr[i]!=0){
                    if(isprim(arr[i]*10+arr[j])){
                        return 1;
                    }
                }
            }
        }
        return 0;
    }
    public static boolean isprim(int x){
        for (int i = 2; i <= Math.sqrt(x); i++) {
            if(x%i==0){
                return false;
            }
        }
        return true;
    }


    /**
     * 17. 电话号码的字母组合
     */
    String[] phone = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    StringBuilder path;
    List<String> ret;
    public List<String> letterCombinations(String digits) {
        path = new StringBuilder();
        ret = new ArrayList<>();
        if(digits.length()==0){
            return ret;
        }
        dfs(digits,0);
        return ret;
    }
    public void dfs(String digits,int pos){
        if(pos==digits.length()){
            ret.add(path.toString());
            return;
        }
        String tmp = phone[digits.charAt(pos)-'0'];
        for (int i = 0; i < tmp.length(); i++) {
            path.append(tmp.charAt(i));
            dfs(digits,pos+1);
            path.deleteCharAt(path.length()-1);
        }
    }

    /**
     * 22. 括号生成
     */
    int left,right,nn;
    StringBuilder ppath;
    List<String> rett;
    public List<String> generateParenthesis(int n) {
        nn  = n;
        ppath = new StringBuilder();
        rett = new ArrayList<>();
        ddfs();
        return rett;
    }
    public void ddfs(){
        if(right==nn){
            rett.add(ppath.toString());
        }
        if(left<nn){
            ppath.append('(');
            left++;
            ddfs();
            ppath.deleteCharAt(ppath.length()-1);
            left--;
        }
        if(right<left){
            ppath.append(')');
            right++;
            ddfs();
            ppath.deleteCharAt(ppath.length()-1);
            right--;
        }
    }


    /**
     * 77. 组合
     */
    List<List<Integer>> Ret;
    List<Integer> Path;
    int n,k;
    public List<List<Integer>> combine(int nn, int kk) {
        Ret = new ArrayList<>();
        Path = new ArrayList<>();
        n=nn;k=kk;
        zh(1);
        return Ret;
    }
    public void zh(int start){
        if(Path.size()==k){
            Ret.add(new ArrayList<>(Path));
        }
        for (int i = start; i <= n; i++) {
            Path.add(i);
            zh(i+1);
            Path.remove(Path.size()-1);
        }
    }



}
class mubiaohe{
    /**
     * 494. 目标和
     */
    int count = 0;
    int t;
    public int findTargetSumWay1s(int[] nums, int target) {
        t = target;
        find(nums,0,0);
        return count;
    }
    public void find(int[] nums,int pos,int path){
        if(pos==nums.length){
            if(path==t){
                count++;
            }
            return;
        }

        //加

        find(nums,pos+1,path+nums[pos]);


        //减
        find(nums,pos+1,path-nums[pos]);

    }
    int path  = 0;
    public int findTargetSumWays(int[] nums, int target) {
        t = target;
        find(nums,0);
        return count;
    }
    public void find(int[] nums,int pos){
        if(pos==nums.length){
            if(path==t){
                count++;
            }
            return;
        }

        //加
        path+=nums[pos];
        find(nums,pos+1);
        path-=nums[pos];

        //减
        path-=nums[pos];
        find(nums,pos+1);
        path+=nums[pos];
    }
}
